from base import _YamlHelper
from page import Page
from page.web_login_page import WebLoginPage


class AcceptgoodsPage(Page):
    acceptgoods_yaml = _YamlHelper().get_config_as_dict('niushop23\\page\\acceptgoods.yaml')['AcceptgoodsPage']

    def acceptgoods_page(self):
        '''输入账户密码'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        login_page.web_login_page('GW', '123456')

    def get_password_text(self):
        '''获取忘记密码文本'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        password_text = login_page.login_text()
        return password_text

    def get_user_name_text(self):
        '''获取用户名称文本'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        username_text = login_page.login_after_text()
        return username_text

    def get_ready_acceptgoods_text(self):
        '''获取待收货文本'''
        driver = self._driver
        acceptgoods_text = driver.get_text(self.acceptgoods_yaml['READY_ACCEPTGOODS_TEXT'])
        return acceptgoods_text

    def get_affirm_acceptgoods_text(self):
        '''获取确认收货文本'''
        driver = self._driver
        affirm_text = driver.get_text(self.acceptgoods_yaml['AFFIRM_ACCEPTGOODS_TEXT'])
        return affirm_text

    def acceptgoods_click(self):
        ''''初始页面登录按钮'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        login_page.click()

    def mouse_to_move(self):
        '''鼠标悬浮'''
        driver = self._driver
        login_page = WebLoginPage(driver)
        login_page.move()

    def personal_center_to(self):
        '''点击个人中心切换新页面'''
        driver = self._driver
        driver.click(self.acceptgoods_yaml['CLICK_PERSONAL_CENTER'])
        driver.switch_to_window_by_index(2)

    def ready_acceptgoods_button(self):
        '''点击待收货按钮'''
        driver = self._driver
        driver.click(self.acceptgoods_yaml['CLICK_READY_ACCEPTGOODS'])

    def affirm_acceptgoods_button(self):
        '''确认收货按钮'''
        driver = self._driver
        driver.click(self.acceptgoods_yaml['CLICK_AFFIRM_ACCEPTGOODS'])
